import request from "@/utils/request";

export interface ResCategory1 {
  id: number;
  name: string;
}
export interface ResCategory2 extends ResCategory1 {
  category1Id: number;
}
export interface ResCategory3 extends ResCategory1 {
  category2Id: number;
}

enum URLS {
  CATEGORY1 = "/product/getCategory1",
  CATEGORY2 = "/product/getCategory2",
  CATEGORY3 = "/product/getCategory3",
}

//获取一级分类
export function requestGetCategory1() {
  return request.get<any, ResCategory1[]>(URLS.CATEGORY1);
}
//获取二级分类
export function requestGetCategory2(category1Id: number) {
  return request.get<any, ResCategory2[]>(`${URLS.CATEGORY2}/${category1Id}`);
}
//获取三级分类
export function requestGetCategory3(category2Id: number) {
  return request.get<any, ResCategory3[]>(`${URLS.CATEGORY2}/${category2Id}`);
}
